home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / EDITSEAR.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  5KB  |  158 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.6  $
  6. //
  7. // Definition of class TEditSearch, an edit control that responds to Find,
  8. // Replace and FindNext menu commands.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_EDITSEAR_H)
  11. #define OWL_EDITSEAR_H
  12.  
  13. #if !defined(OWL_EDIT_H)
  14. # include <owl/edit.h>
  15. #endif
  16. #if !defined(OWL_FINDREPL_H)
  17. # include <owl/findrepl.h>
  18. #endif
  19. #include <owl/editsear.rh>
  20.  
  21. #if defined(BI_NAMESPACE)
  22. namespace OWL {
  23. #endif
  24.  
  25. // Generic definitions/compiler options (eg. alignment) preceeding the 
  26. // definition of classes
  27. #include <services/preclass.h>
  28.  
  29. //
  30. // class TEditSearch
  31. // ~~~~~ ~~~~~~~~~~~
  32. class _OWLCLASS TEditSearch : public TEdit {
  33.   public:
  34.     TEditSearch(TWindow*        parent = 0,
  35.                 int             id = 0,
  36.                 const char far* text = 0,
  37.                 int x = 0, int y = 0, int w = 0, int h = 0,
  38.                 TModule*        module = 0);
  39.  
  40.     // NOTE: The following constructor, which aliases an Edit control created
  41.     //       from a dialog resource is 'unconventional' in that it expects
  42.     //       a TModule reference instead of the traditional 'TModule* = 0'.
  43.     //       This is, however, to avoid ambiguities between the two forms
  44.     //       of constructor. Since it is traditionally created as a child
  45.     //       of a TDialog-derived class, you can simply use the module of the
  46.     //       parent object. 
  47.     //       For example,
  48.     //             TMyDialog::TMyDialog(....) {
  49.     //                edit = new TEditSearch(this, ID_EDIT1, *GetModule());
  50.     //             }
  51.     //
  52.     TEditSearch(TWindow*   parent,
  53.                 int        resourceId,
  54.                 TModule&   module);
  55.  
  56.    ~TEditSearch();
  57.  
  58.     void          SetupWindow();
  59.     void          DoSearch();
  60.  
  61.     TFindReplaceDialog::TData& GetSearchData();
  62.     void          SetSearchData(const TFindReplaceDialog::TData& searchdata);
  63.  
  64.     TFindReplaceDialog* GetSearchDialog();
  65.     void          SetSearchDialog(TFindReplaceDialog* searchdialog);
  66.  
  67.     uint          GetSearchCmd();
  68.     void          SetSearchCmd(uint searchcmd);
  69.  
  70.   protected: 
  71.  
  72.     // Menu command handlers
  73.     //
  74.     void          CmEditFind();               // CM_EDITFIND
  75.     void          CmEditReplace();            // CM_EDITREPLACE
  76.     void          CeEditFindReplace(TCommandEnabler& ce);
  77.     void          CmEditFindNext();           // CM_EDITFINDNEXT
  78.     void          CeEditFindNext(TCommandEnabler& ce);
  79.  
  80.     TResult       EvFindMsg(TParam1, TParam2);  // Registered commdlg message
  81.  
  82.   public_data:
  83.     TFindReplaceDialog::TData SearchData;
  84.     TFindReplaceDialog*       SearchDialog;  // Find or replace dialog
  85.     uint                      SearchCmd;     // command set that opened dialog
  86.  
  87.   private:
  88.     // Hidden to prevent accidental copying or assignment
  89.     //
  90.     TEditSearch(const TEditSearch&);
  91.     TEditSearch& operator=(const TEditSearch&);
  92.  
  93.   DECLARE_RESPONSE_TABLE(TEditSearch);
  94.   DECLARE_STREAMABLE(_OWLCLASS, TEditSearch, 1);
  95. };
  96.  
  97. // Generic definitions/compiler options (eg. alignment) following the 
  98. // definition of classes
  99. #include <services/posclass.h>
  100.  
  101. #if defined(BI_NAMESPACE)
  102. } // namespace OWL
  103. #endif
  104.  
  105. //----------------------------------------------------------------------------
  106. // Inline implementations
  107. //
  108. inline
  109. TEditSearch::TEditSearch(TWindow* parent, int resourceId, TModule& module)
  110.             :TEdit(parent, resourceId, 0, &module)
  111. {
  112. }
  113.  
  114. //
  115. // Return the search data used for the common dialog.
  116. //
  117. inline TFindReplaceDialog::TData& TEditSearch::GetSearchData() {
  118.   return SearchData;
  119. }
  120.  
  121. //
  122. // Use new search data.
  123. //
  124. inline void TEditSearch::SetSearchData(const TFindReplaceDialog::TData& searchdata) {
  125.   SearchData = searchdata;
  126. }
  127.  
  128. //
  129. // Return the common dialog pointer.
  130. //
  131. inline TFindReplaceDialog* TEditSearch::GetSearchDialog() {
  132.   return SearchDialog;
  133. }
  134.  
  135. //
  136. // Use new common dialog pointer.
  137. //
  138. inline void TEditSearch::SetSearchDialog(TFindReplaceDialog* searchdialog) {
  139.   SearchDialog = searchdialog;
  140. }
  141.  
  142. //
  143. // Return the user selected command that brought up the search dialog.
  144. //
  145. inline uint TEditSearch::GetSearchCmd() {
  146.   return SearchCmd;
  147. }
  148.  
  149. //
  150. // Remember the command the user selected to bring up the search dialog.
  151. //
  152. inline void TEditSearch::SetSearchCmd(uint searchcmd) {
  153.   SearchCmd = searchcmd;
  154. }
  155.  
  156.  
  157. #endif  // OWL_EDITSEAR_H
  158.